<?php
namespace app\common\model;

use think\Model;

class Contract extends Model
{
    //合同列表
    public function getcontractlist($where,$page,$limit)
    {
        $list = db('contract')
            ->alias('c')
            ->field("a.username,co.company_name,c.contract_id,c.content,from_unixtime(c.start_time,'%Y .%m .%d %H:%i:%s') start_time,from_unixtime(c.end_time,'%Y .%m .%d %H:%i:%s') end_time,c.contract_id")
            ->join('company co',"co.company_id = c.company_id","left")
            ->join('admin a',"a.admin_id = c.admin_id","left")
            ->page($page, $limit)
            ->where($where)
            ->select();
        $count = db('contract')
            ->alias('c')
            ->field("a.username,co.company_name,c.contarct_id,c.content,from_unixtime(c.start_time,'%Y .%m .%d %H:%i:%s') start_time,from_unixtime(c.end_time,'%Y .%m .%d %H:%i:%s') end_time,c.contract_id")
            ->join('company co',"co.company_id = c.company_id","left")
            ->join('admin a',"a.admin_id = c.admin_id","left")
            ->where($where)
            ->count();
//        foreach ($list as $k => $v) {
//            //下属部门数量
//            $list[$k]['content'] = htmlspecialchars_decode( $list[$k]['content']);
//        }
        return ['count' => $count, 'data' => $list];
    }
}